function [data] = coherent(s_2dpsk, ht)

    n = length(s_2dpsk);
    data_temp = zeros(1,n);
    data = zeros(1,n);
    
    count = 1;
    s_2dpsk1 = s_2dpsk.*ht;
    for k = 1 : n
        if(mod(k,8) == 1 && k ~= 1)
            count = count + 1;
        end
        if (mod(k,8) == 5)
            if (s_2dpsk1(k) == 1)
                data_temp(count) = 1;
            else
                data_temp(count) = 0;
            end
        end
    end
    
    data_temp = data_temp(1, 1:2:end);
    
    for n = 1 : length(data_temp)
        if (n == 1)
            if (data_temp(n)==0)
                data(n) = 0;
            else
                data(n) = 1;
            end
        else
            if (data_temp(n) == data_temp(n-1))
                data(n) = 0;
            else
                data(n) = 1;
            end
        end
    end
end

